package com.controller;

import com.pojo.Area;
import com.service.AreaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("area")
@Slf4j
public class AreaControllerOutApi {

    @Resource
    private AreaService areaService;

    /**
     * 循环获取
     * @param pid
     * @return
     */
    //@ApiOperation(value = "行政区域列表查询", notes = "行政区域列表查询")
    @GetMapping("/list/area/{pid}")
    public List<Area> listDistinct(/*@ApiParam(value = "查询条件", required = true)*/ @PathVariable("pid") String pid){
        if (StringUtils.isEmpty(pid) || "undefined".equals(pid)){
            pid = "0";
        }
        return areaService.selectDisList(pid);
    };

    /**
     * 递归一次性加载行政区域
     * @return
     */
    @GetMapping("/list/all")
    public List<Area> listDistinctAll() {
        List<Area> list = areaService.selectListAll();
        return list;
    }

}
